from flask import Blueprint, render_template, request, jsonify, url_for, redirect
from flask_login import login_required, current_user
from app.models import Auth

index_controller = Blueprint("index", __name__)

@index_controller.route('/')
@login_required
def index():
    # 获取登录角色id
    auth_ids = []
    if current_user.role.auths:
        for auth in current_user.role.auths:
            auth_ids.append(auth.id)
    menu = Auth.menu_tree(auth_ids)
    return render_template("index.html", menu = menu)

@index_controller.route('/welcome')
@login_required
def welcome():

    return render_template("welcome.html")